<?php

namespace App\Http\Controllers\Api\v1;

use App\Http\Controllers\Controller;
use App\Models\Seach;
use App\server\RedisServer;
use Illuminate\Http\Request;
use App\common;
use App\Logic\SeachLogic;

/**
 * Undocumented class
 * 搜索模块控制器
 * @name zf
 */
class SeachController extends Controller
{
    //
    /**
     * Undocumented function
     *  搜索列表
     * @return void
     */
    public function seachList(){
        try{
            $seachList=SeachLogic::seachList();
            return common::success(20000,$seachList,'加载成功');
        }catch(\Exception  $e){
            return common::fail(2001,'',$e->getMessage());
        }
    }

    /**
     * Undocumented function
     *  搜索信息存入es
     * @return void
     */
    public function seachEsCreate(){
        try{
            $seachEsCreate=Seach::list()->toArray();
            $res=SeachLogic::SeachEsCreate($seachEsCreate);
            return common::success(20000,$res,'加载成功');
        }catch(\Exception  $e){
            return common::fail(2001,'',$e->getMessage());
        }
    }
    /**
     * Undocumented function
     *  搜索信息es搜索
     * @return void
     */
    public function realeEstateEsIdex(Request $request){
        try{
            $name=$request->get('name');
            $realeEstateData=SeachLogic::SeachEsIndex($name);
            return common::success(20000,$realeEstateData,'加载成功');
        }catch(\Exception  $e){
            return common::fail(2001,'',$e->getMessage());
        }
    }
    /**
     * Undocumented function
     *  楼盘列表
     * @return void
     */
    public function seachRank(){
        try{
            $seachList=SeachLogic::seachRank();
            return common::success(20000,$seachList,'加载成功');
        }catch(\Exception  $e){
            return common::fail(2001,'',$e->getMessage());
        }
    }

}
